package com.linkivr.action;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;
import org.springframework.stereotype.Component;

import com.opensymphony.xwork2.ActionSupport;

@Component("myAction")
public class MyAction extends ActionSupport {

	private static final long serialVersionUID = 1L;

	protected HttpServletRequest request = null;
	protected HttpServletResponse response = null;
	protected PrintWriter out = null;
	protected HttpSession session = null;
	protected String jsonString;
	protected int start;
	protected int limit;

	public String getJsonString() {
		return jsonString;
	}

	public void setJsonString(String jsonString) {
		this.jsonString = jsonString;
	}

	public int getStart() {
		return start;
	}

	public void setStart(int start) {
		this.start = start;
	}

	public int getLimit() {
		return limit;
	}

	public void setLimit(int limit) {
		this.limit = limit;
	}

	public void beginReqParam() throws IOException {

		request = ServletActionContext.getRequest();
		request.setCharacterEncoding("utf-8");

		response = ServletActionContext.getResponse();
		response.setContentType("text/html");
		response.setContentType("text/html;charset=utf-8");
		response.setCharacterEncoding("utf-8");

		out = response.getWriter();
		session = request.getSession(false);
	}

	public void endReqParam() {
		out.flush();
		out.close();
		out = null;
		session = null;

		request = null;
		response = null;
	}

}
